import { getAction, putAction, postAction, deleteAction } from '@/api/manage'
import { serviceApi } from '@/api/common.js'
/**
 * 公共API接口
 */
export const api = {
  projectsList: serviceApi.auth + '/assets/projects',
  projectsDelete: id => `assets/projects/${id}`,
  myProjectList: serviceApi.auth + '/assets/projects/myProjects', // 获取我的项目列表
  deviceList: serviceApi.auth + '/assets/devices', // s设备列表
  deleteDeviceList: id => `/assets/devices/${id}`, // s设备列表
  deviceListByProjId: projectId => serviceApi.auth + `/assets/devices/${projectId}/devices` // 通过项目ID获取设备列表
}

/**
 * 新增项目
 * @param parameter
 * @returns {*}
 */
export const projectCreate = params => postAction('/assets/projects', params)

/**
 * 编辑项目
 * @param parameter
 * @returns {*}
 */
export const projectEdit = params => putAction('/assets/projects', params)

/**
 * 通过ID查询项目信息
 * @param parameter
 * @returns {*}
 */
export const getProjectById = (id, params) => getAction(serviceApi.auth + `/assets/projects/${id}`, params)

/**
 * 通过ID获取设备信息
 * @param {*} params
 * @returns
 */
export const getDeviceById = (id, params) => getAction(serviceApi.auth + `/assets/devices/${id}`, params)

/**
 * 通过项目ID获取设备列表
 * @param {*} params
 * @returns
 */
// export const getDevicesByProjId = params => getAction('/assets/device/devicesById', params);

/**
 * 新增项目
 * @param parameter
 * @returns {*}
 */
export const deviceCreate = params => postAction('/assets/devices', params)

/**
 * 编辑项目
 * @param parameter
 * @returns {*}
 */
export const deviceEdit = params => putAction('/assets/devices', params)
